package llm

import (
	"context"

	"github.com/tmc/langchaingo/llms"
	"github.com/tmc/langchaingo/llms/openai"
)

var llm *openai.LLM

func init() {
	llm, _ = openai.New(
		openai.WithBaseURL("https://open.bigmodel.cn/api/paas/v4/"),
		openai.WithModel("glm-4-plus"),
		openai.WithToken("40fd3f3a20e176b232c9907add431660.mCUiGFa72GBBDZt7"),
	)
}

func Chat(content []llms.MessageContent) string {
	ctx := context.Background()
	res, _ := llm.GenerateContent(ctx, content, llms.WithMaxTokens(2048), llms.WithTemperature(0.8))
	return res.Choices[0].Content
}